<title>控制台</title>
<div class="layui-card layadmin-header">
    <div class="layui-breadcrumb">
        <a lay-href="">主页</a>
        <a><cite>控制台</cite></a>
        <a><cite>控制台</cite></a>
    </div>
</div>
<script type="text/html" id="formTpl">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md9">
            <div class="layui-row layui-col-space15">
                <div class="layui-col-md5">
                    <div class="layui-card">
                        <div class="layui-card-header">快捷入口</div>
                        <div class="layui-card-body">
                            <div class="layui-carousel layadmin-carousel layadmin-shortcut">
                                <div carousel-item>
                                    {{# if(d.menuList){ }}
                                        {{# let len = d.menuList.length;
                                            let x = 8;
                                            let j = 0;
                                            if(len > 0){
                                                j = Math.ceil(len / x);
                                            }
                                            let k = 0;
                                            let count = 0;
                                        }}
                                        {{#
                                            for(let i = 0;i < j;i++){
                                                count = (i + 1) * x;
                                                if(count > len){
                                                    count = x - (count - len);
                                                }else{
                                                    count = x;
                                                }
                                        }}
                                    <ul class="layui-row layui-col-space10">
                                            {{# for(let w = 0;w < count;w++){ }}
                                                {{#
                                                    let menuData = d.menuList[k], arr = [];
                                                    if(menuData && (typeof menuData == 'object' || typeof menuData == 'Object') ){
                                                        let obj = Object.values(menuData);
                                                        if(obj.length > 0){
                                                            arr = obj;
                                                        }
                                                    }
                                                }}
                                        <li class="layui-col-xs3">
                                            <a lay-href="{{ arr[2] }}">
                                                <i class="layui-icon layui-icon-console iconfont {{ arr[1] }}"></i>
                                                <cite>{{ arr[0] }}</cite>
                                            </a>
                                        </li>
                                                {{# k++; }}
                                            {{# } }}
                                    </ul>
                                        {{# } }}
                                    {{# } }}
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="layui-col-md7">
                    <div class="layui-card">
                        <div class="layui-card-header">数据统计</div>
                        <div class="layui-card-body">
                            <div class="layui-carousel layadmin-carousel layadmin-backlog" data-autoplay="true" data-interval="15000">
                                <div carousel-item>
                                    <ul class="layui-row layui-col-space10">
                                        <li class="layui-col-xs4">
                                            <a lay-href="user/user/index" class="layadmin-backlog-body">
                                                <h3>微信用户数</h3>
                                                <p><cite>{{ d.user_total }}</cite></p>
                                            </a>
                                        </li>
                                        <li class="layui-col-xs4">
                                            <a lay-href="activity/project/index" class="layadmin-backlog-body">
                                                <h3>项目数</h3>
                                                <p><cite>{{ d.project_total }}</cite></p>
                                            </a>
                                        </li>
                                        <li class="layui-col-xs4">
                                            <a lay-href="program/organize/index" class="layadmin-backlog-body">
                                                <h3>机构数</h3>
                                                <p><cite>{{ d.organize_total }}</cite></p>
                                            </a>
                                        </li>
                                        <li class="layui-col-xs4">
                                            <a lay-href="program/information/index" class="layadmin-backlog-body">
                                                <h3>资讯数</h3>
                                                <p><cite>{{ d.information_total }}</cite></p>
                                            </a>
                                        </li>
                                        <li class="layui-col-xs4">
                                            <a lay-href="prize/prizeRecord/index" class="layadmin-backlog-body">
                                                <h3>奖品发放数</h3>
                                                <p><cite>{{ d.prize_record_total }}</cite></p>
                                            </a>
                                        </li>
                                        <li class="layui-col-xs4">
                                            <a lay-href="sms/smsRecord/index" class="layadmin-backlog-body">
                                                <h3>短信记录</h3>
                                                <p><cite>{{ d.sms_record_total }}</cite></p>
                                            </a>
                                        </li>
                                    </ul>
                                    <ul class="layui-row layui-col-space10">
                                        <li class="layui-col-xs4">
                                            <a lay-href="activity/activity/index" class="layadmin-backlog-body">
                                                <h3>活动数</h3>
                                                <p><cite>{{ d.activity_total_list[0] }}</cite></p>
                                            </a>
                                        </li>
                                        <li class="layui-col-xs4">
                                            <a lay-href="activity/activity/index" class="layadmin-backlog-body">
                                                <h3>未发布</h3>
                                                <p><cite>{{ d.activity_total_list[1] }}</cite></p>
                                            </a>
                                        </li>
                                        <li class="layui-col-xs4">
                                            <a lay-href="activity/activity/index" class="layadmin-backlog-body">
                                                <h3>已发布</h3>
                                                <p><cite>{{ d.activity_total_list[2] }}</cite></p>
                                            </a>
                                        </li>
                                        <li class="layui-col-xs4">
                                            <a lay-href="activity/activity/index" class="layadmin-backlog-body">
                                                <h3>已结束</h3>
                                                <p><cite style="color: #FF5722;">{{ d.activity_total_list[3] }}</cite></p>
                                            </a>
                                        </li>
                                        <li class="layui-col-xs4">
                                            <a lay-href="activity/activity/index" class="layadmin-backlog-body">
                                                <h3>已关闭</h3>
                                                <p><cite style="color: #FF5722;">{{ d.activity_total_list[4] }}</cite></p>
                                            </a>
                                        </li>
                                    </ul>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="layui-col-md3">
            <div class="layui-card">
                <div class="layui-card-header">版本信息</div>
                <div class="layui-card-body layui-text layadmin-version">
                    <table class="layui-table">
                        <colgroup>
                            <col width="100">
                            <col>
                        </colgroup>
                        <tbody>
                            <tr>
                                <td>系统版本</td>
                                <td>{{ d.version }}</td>
                            </tr>
                            <tr>
                                <td>UI版本</td>
                                <td>v{{ layui.cache.version }}</td>
                            </tr>
                            <tr>
                                <td>网站名称</td>
                                <td>{{ d.site_name }}</td>
                            </tr>
                            <tr>
                                <td>PHP版本</td>
                                <td>v{{= d.php_version }}</td>
                            </tr>
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
    </div>
</script>
<div class="layui-fluid" id="formView">

</div>
<script src="../web/res/js/common/echarts/echarts.js"></script>
<script>
    layui.use(['admin', 'carousel'], function () {
        let $ = layui.$
            , admin = layui.admin
            , setter = layui.setter
            , carousel = layui.carousel
            , element = layui.element
            , form = layui.form
            , laytpl = layui.laytpl
            , view = layui.view
            , device = layui.device();

        element.render('progress');
        admin.req({
            url: setter.request.domainName + '/admin/Console/index'
            , data: {}
            , type: 'get'
            , loading: false // 是否开启加载框
            , done: function (res) {
                try {
                    let data = res.data;
                    let getTpl = $("#formTpl").html();
                    laytpl(getTpl).render(res.data, function (string) {
                        $("#formView").html(string);
                        form.render();
                        //轮播切换
                        $('.layadmin-carousel').each(function () {
                            let othis = $(this);
                            carousel.render({
                                elem: this
                                , width: '100%'
                                , arrow: 'none'
                                , interval: othis.data('interval')
                                , autoplay: othis.data('autoplay') === true
                                , trigger: (device.ios || device.android) ? 'click' : 'hover'
                                , anim: othis.data('anim')
                            });
                        });
                    });
                }catch (e) {
                    console.error(e)
                    view.message({
                        title: '数据异常！'
                        , icon: 2
                        , time: 1500
                    })
                }
            }
        })
    });
</script>

